import server from "./server"

enum Methods {
    GET = "get",
    Post = "post",
}
export const fetchGet: Function = (url: string, params: any) => {
    return new Promise((resolve, reject) => {
        server({
            url,
            method: Methods.GET,
            params
        }).then(res => {
            resolve(res.data)
        }).catch(err => {
            reject(err)
        })
    })
}

export const fetchPost: Function = (url: string, data: any) => {
    return new Promise((resolve, reject) => {
        server({
            url,
            method: Methods.Post,
            data,
        }).then(res => {
            resolve(res.data)
        }).catch(err => {
            reject(err)
        })
    })
}